package com.java110.mall.goods.smo.impl;


import com.java110.intf.goods.IShopDistributionModeInnerServiceSMO;
import com.java110.dto.shop.ShopDistributionModeDto;
import com.java110.mall.goods.dao.IShopDistributionModeServiceDao;
import com.java110.po.shop.ShopDistributionModePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 派送方式与商品关系内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopDistributionModeInnerServiceSMOImpl extends BaseServiceSMO implements IShopDistributionModeInnerServiceSMO {

    @Autowired
    private IShopDistributionModeServiceDao shopDistributionModeServiceDaoImpl;


    @Override
    public int saveShopDistributionMode(@RequestBody  ShopDistributionModePo shopDistributionModePo) {
        int saveFlag = 1;
        shopDistributionModeServiceDaoImpl.saveShopDistributionModeInfo(BeanConvertUtil.beanCovertMap(shopDistributionModePo));
        return saveFlag;
    }

     @Override
    public int updateShopDistributionMode(@RequestBody  ShopDistributionModePo shopDistributionModePo) {
        int saveFlag = 1;
         shopDistributionModeServiceDaoImpl.updateShopDistributionModeInfo(BeanConvertUtil.beanCovertMap(shopDistributionModePo));
        return saveFlag;
    }

     @Override
    public int deleteShopDistributionMode(@RequestBody  ShopDistributionModePo shopDistributionModePo) {
        int saveFlag = 1;
        shopDistributionModePo.setStatusCd("1");
        shopDistributionModeServiceDaoImpl.updateShopDistributionModeInfo(BeanConvertUtil.beanCovertMap(shopDistributionModePo));
        return saveFlag;
    }

    @Override
    public List<ShopDistributionModeDto> queryShopDistributionModes(@RequestBody  ShopDistributionModeDto shopDistributionModeDto) {

        //校验是否传了 分页信息

        int page = shopDistributionModeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopDistributionModeDto.setPage((page - 1) * shopDistributionModeDto.getRow());
        }

        List<ShopDistributionModeDto> shopDistributionModes = BeanConvertUtil.covertBeanList(shopDistributionModeServiceDaoImpl.getShopDistributionModeInfo(BeanConvertUtil.beanCovertMap(shopDistributionModeDto)), ShopDistributionModeDto.class);

        return shopDistributionModes;
    }
    @Override
    public List<ShopDistributionModeDto> getShopDistributionModeAll(@RequestBody  ShopDistributionModeDto shopDistributionModeDto) {

        List<ShopDistributionModeDto> shopDistributionModes = BeanConvertUtil.covertBeanList(shopDistributionModeServiceDaoImpl.getShopDistributionModeAll(BeanConvertUtil.beanCovertMap(shopDistributionModeDto)), ShopDistributionModeDto.class);

        return shopDistributionModes;
    }


    @Override
    public int queryShopDistributionModesCount(@RequestBody ShopDistributionModeDto shopDistributionModeDto) {
        return shopDistributionModeServiceDaoImpl.queryShopDistributionModesCount(BeanConvertUtil.beanCovertMap(shopDistributionModeDto));    }

    public IShopDistributionModeServiceDao getShopDistributionModeServiceDaoImpl() {
        return shopDistributionModeServiceDaoImpl;
    }

    public void setShopDistributionModeServiceDaoImpl(IShopDistributionModeServiceDao shopDistributionModeServiceDaoImpl) {
        this.shopDistributionModeServiceDaoImpl = shopDistributionModeServiceDaoImpl;
    }
}
